package com.xp.code.view;

import javax.annotation.Resource;

import net.sf.json.JSONObject;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ModelDriven;
import com.xp.code.servicesImpl.UserInfoService;
import com.xp.code.vo.UserInfoVO;

/**
 * 
 * @author HAHA
 * 
 */
@Controller("userInfoAction")
@Scope("prototype")
public class UserInfoAction extends XPInfoAction implements
		ModelDriven<UserInfoVO> {

	private UserInfoVO userInfoVO;
	@Resource(name="userInfoService")
	private UserInfoService userInfoService;
	
	public UserInfoAction() {

	}

	public UserInfoVO getModel() {
		userInfoVO = new UserInfoVO();
		return userInfoVO;
	}

	public UserInfoService getUserInfoService() {
		return userInfoService;
	}

	public void setUserInfoService(UserInfoService userInfoService) {
		this.userInfoService = userInfoService;
	}
	
	public String addUserInfos(UserInfoVO userInfoVO) throws Exception {
		UserInfoVO vo=this.userInfoService.addUserInfos(userInfoVO);
		this.userInfoVO.setErrno(vo.getErrno());
		this.userInfoVO.setErrmsg(vo.getErrmsg());
		JSONObject jo=JSONObject.fromObject(vo);
		this.setJsonString(jo.toString());
		return SUCCESS;
	}

}
